<template>
  <div class="my-tag">
    <input class="input" type="text" placeholder="输入标签" @blur="changeInput" v-model="msg" v-if="isShow" v-focus ref="myInput" />
    <div class="text" @dblclick='changeFlag' v-else>{{value}}</div>
  </div>
</template>

<script>
export default {
  props:{
    value:{
      type:[String,Number],
      required:true,
      default:()=>{}
    }
  },
  data() {
    return {
      isShow:false,
      msg:''
    }
  },
  methods: {
    changeFlag(){
      this.isShow=!this.isShow
      this.msg=this.value
    },
    changeInput(){
      this.isShow=!this.isShow

      this.$emit('input',this.msg)
    }
  },
}
</script>

<style scoped lang='less'>
.my-tag {
  cursor: pointer;
  .input {
    appearance: none;
    outline: none;
    border: 1px solid #ccc;
    width: 100px;
    height: 40px;
    box-sizing: border-box;
    padding: 10px;
    color: #666;
    &::placeholder {
      color: #666;
    }
  }
}
</style>
